﻿
CREATE TABLE [dbo].[SimpleQueue] (
	[Id] [varchar](26) NOT NULL,
	[OptionalKey] [nvarchar](440) NULL,
	[QueueName] [nvarchar](440) NOT NULL,
	[Payload] [varbinary](max) NOT NULL,
	[CreatedAt] [datetime] NOT NULL,
	[ModifiedAt] [datetime] NOT NULL,
	[AckDate] [datetime] NULL,
	[HandlersCount] [int] NOT NULL,
	[DeliveryDate] [datetime] NULL,
	[Locked] [bit] NOT NULL,
    CONSTRAINT [PK_SimpleQueue] PRIMARY KEY ([Id])
)
GO

CREATE NONCLUSTERED INDEX [IX_SimpleQueue_NextDelivery] ON [dbo].[SimpleQueue]
(
	[QueueName] ASC,
	[ModifiedAt] ASC
)
GO

CREATE NONCLUSTERED INDEX [IX_SimpleQueue_Key] ON [dbo].[SimpleQueue]
(
	[OptionalKey] ASC
)

GO
CREATE STATISTICS [_dta_stat_309576141_3_9_10] ON [dbo].[SimpleQueue]([QueueName], [DeliveryDate], [Locked])
GO
CREATE STATISTICS [_dta_stat_309576141_5] ON [dbo].[SimpleQueue]([CreatedAt])
GO
CREATE STATISTICS [_dta_stat_309576141_9_10_7] ON [dbo].[SimpleQueue]([DeliveryDate], [Locked], [AckDate])
GO

CREATE NONCLUSTERED INDEX [IX_SimpleQueue_4Columns_2Includes] ON [dbo].[SimpleQueue]
(
	[ModifiedAt] ASC,
	[QueueName] ASC,
	[DeliveryDate] ASC,
	[Locked] ASC
)
INCLUDE 
(
	[Id],
	[AckDate]
) 
WITH (SORT_IN_TEMPDB = OFF)

GO
